<!-- 添加/编辑 收件地址-->
<template>
	<div class="page-common">
		<nav-bar :back="1" :title="'自我测评'"></nav-bar>
		<div class="page-panel">
			<van-pull-refresh
			v-model="refreshing"
			success-text="刷新成功"
			@refresh="onRefresh"
		>
			<van-list
				v-if="serverItem.length > 0"
				v-model="loading"
				:finished="finished"
				finished-text="没有更多了"
				@load="onLoad"
			>
				<div v-for="item in serverItem" :key="item.Id" @click="goUrl(item.LinkUrl)">
					<van-row type="flex" justify="space-between">
						<van-col span="18">
							<div class="server-item server-item-bb">
								<div class="server-name">{{item.Title}}</div>
							</div>
						</van-col>
						<van-col span="5">
							<div class="server-item server-item-bb server-item-right">
								去测试
							</div>
						</van-col>
						<van-col span="1">
							<div class="server-item server-item-bb">
								<van-image width="0.14rem" height="0.24rem" :src="arrowsRight"></van-image>
							</div>
						</van-col>
					</van-row>
				</div>
			</van-list>
			<div v-else class="default-page">
				<default-page :hint="hint"></default-page>
			</div>
		</van-pull-refresh>

		
		</div>
	</div>
</template>

<script>
	import {
		Toast,
		Dialog,
		Picker
	} from 'vant'

	import NavBar from '../../components/NavBar.vue'
  import DefaultPage from '../../components/DefaultPage.vue'

	import {
		mymessage_api
	} from '../../api/index.js'

	export default {
		name: 'addressedit',
		components: {
			NavBar,
			DefaultPage
		},
		data() {
			return {
					serverItem: [
					// 	{
					// 	name: '当前测试标题A',
					// 	link: "https://www.baidu.com",
					// 	img: require('../../assets/imgs/address.png')
					// },
					// {
					// 	name: '当前测试标题B',
					// 	link: '',
					// 	img: require('../../assets/imgs/about_us.png')
					// },
					// {
					// 	name: '当前测试标题C',
					// 	link: '',
					// 	img: require('../../assets/imgs/contact_us.png')
					// }
				],
				arrowsRight: require('../../assets/imgs/arrowsRight.png'), //箭头右
				refreshing: false,
				loading: false,
				finished: false,
				pageIndex: 1,
				hint: '暂无数据',
			}
		},
		activated() {
			this.getList(false)
		},
		methods: {
			rollback() {
				this.$router.back(-1)
			},
			goUrl(url) {
				window.location.href = url;
			},
			onLoad() {
				setTimeout(() => {
					if (this.refreshing) {
						this.pageIndex = 1
						// this.addressList = [];
						Toast('刷新成功')
					} else {
						this.pageIndex++
					}

					this.getList()

					this.loading = false
				}, 1000)
			},
			getList(is_push = true) {
				let data = {
					PageIndex: this.pageIndex,
						PageSize: 10,
				}
				mymessage_api.getMyselfTestlist(data, (res) => {
					console.log('getList', res)
					if (this.refreshing || !is_push) {
						this.serverItem = res
					} else {
						this.serverItem.push(...res)
					}
					this.refreshing = false
					if (res.length < 20) {
						this.finished = true //已全部加载
					}
				})
			},
			onRefresh() {
				this.loading = true
				this.onLoad()
			},
		},
	}
</script>

<style scoped>
	.page-common {
		width: 100%;
		height: 100%;
		background-color: #FFFFFF;
		padding-top: 0.88rem;
	}
	.page-panel{
		min-height: calc(100vh - 0.88rem);
		font-size: 0.28rem;
	}
	.van-row{
		height: 1.28rem;
		line-height: 1.28rem;
		padding: 0 0.3rem;
		color: #A6A6A6;
		border-bottom: 1px solid #F6F5FB;
	}
	.van-row::after {
		border-bottom: 1px solid #e0e0e0;
	}
	.server-item-bb {
		/* border-bottom: 1px solid #F6F5FB; */
		padding-left: 0.04rem;
	}
	.server-name {
		font-size: 0.28rem;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #000000;
	}
	.server-item-right{
		text-align: right;
		padding-right: 0.06rem;
	}
</style>
